package com.yztc.ui.cook.categoryinfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yztc.bean.cook.CookbooklistBean;
import com.yztc.chunboapp.R;
import com.yztc.utils.ImageHelper;

import java.util.List;

import static android.R.attr.duration;

/**
 * Created by Administrator on 2016/10/8.
 */
public class CategoryInfoAdapter extends BaseAdapter{
    private Context mContext;
    private List<CookbooklistBean> list;
    private LayoutInflater inflater;

    public CategoryInfoAdapter(Context mContext, List<CookbooklistBean> list){
        this.mContext=mContext;
        this.list=list;
        inflater= (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder myViewHolder=null;
        if(convertView==null){
            convertView=inflater.inflate(R.layout.activity_category_item,parent,false);
            myViewHolder=new MyViewHolder(convertView);
            convertView.setTag(myViewHolder);
        }else {
            myViewHolder= (MyViewHolder) convertView.getTag();
        }
        myViewHolder.tv_name_category.setText(list.get(position).getChefName());
        myViewHolder.tv_title_category.setText(list.get(position).getDisplayName());
        myViewHolder.tv_info_category.setText(list.get(position).getDescription());
        ImageHelper.getRoundImage(mContext,list.get(position).getChefImg(),myViewHolder.img_name_category);
        ImageHelper.getNormalImage(mContext,list.get(position).getPicUrl(),myViewHolder.img_food_category);
        return convertView;
    }

    class MyViewHolder{
        private ImageView img_food_category;
        private ImageView img_name_category;
        private TextView tv_name_category;
        private TextView tv_title_category;
        private TextView tv_info_category;
        public MyViewHolder(View convertView){
            img_food_category=
                    (ImageView) convertView.findViewById(R.id.img_category);
            img_name_category=
                    (ImageView) convertView.findViewById(R.id.img_name_category);
            tv_name_category=
                    (TextView) convertView.findViewById(R.id.tv_name_category);
            tv_title_category=
                    (TextView) convertView.findViewById(R.id.tv_title_category);
            tv_info_category=
                    (TextView) convertView.findViewById(R.id.tv_info_category);
        }
    }
}
